package com.ninong.ker.admin.rest.vo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @author cmd
 */
@Data
public class MenuVO implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 4270270880398262615L;

    private String id;
    private String uid;

    /**
     * 上级菜单ID
     */
    private String pid;

    /**
     * 菜单类型
     */
    private String type;

    /**
     * 菜单标题
     */
    private String name;

    /**
     * 图标
     */
    private String icon;

    /**
     * 路径
     */
    private String path;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 权限
     */
    private String permission;

    /**
     * 组件路由
     */
    private String component;

    private Date createTime;

    /**
     * 修改时间
     */
    private Date updateTime;

    private List<MenuVO> children;
    private JSONObject meta;
    /**
     * 参数
     */
    private String param;
//    private JSONObject params;
//
//    public JSONObject getParams() {
//        JSONObject params = new JSONObject();
//        params.put("formId", "c8f85c4378958df8d84a43874764817e");
//        params.put("id", "98d99b0580cc96ca418052c5eff0fa15");
//        return params;
//    }
//
//    public void setParams(JSONObject params) {
//        this.params = params;
//    }

    public JSONObject getMeta() {
        JSONObject meta = null;
        if (StringUtils.isNotEmpty(param)) {
            meta = JSONObject.parseObject(param);
        } else {
            meta = new JSONObject();
        }
        meta.put("icon", icon);
        meta.put("title", name);
        return meta;
    }

    public void setMeta(JSONObject meta) {
        this.meta = meta;
    }
}
